<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 12-7-20
 * Time: 下午9:10
 * To change this template use File | Settings | File Templates.
 */
class FileController extends Controller
{
    /**
     * 相册
     */
    public function AlbumAction()
    {

        $result = UploadTool::doImages('Filedata');

        if(!$result){
            echo '{"result":"0","msg":"上传文件失败"}';
            exit;
        }

        /** 添加到相册表中 **/
        $data = array(
            'fid'       => $_REQUEST['fid'],
            'photo'     => $result['url'],
            'created'   => TIME
        );
        $aid = FarmsAlbumModel::getInstance()->addPhoto($data);

        echo '{"result":"1","msg":"文件上传成功","img":"'.$result['url'].'","aid":"'.$aid.'"}';
        exit;
    }

    public function DelphotoAction()
    {
        $pid = $_REQUEST['pid'];
        if (FarmsAlbumModel::getInstance()->delPhoto($pid)) {
            echo '{"status":"1","msg":"图片删除成功"}';
            exit;
        }
    }

}
